package com.servlet.JeuDeLaBiere;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.servlet.JeuDeLaBiere.Model.Main;

public class ServletPlayerForm extends HttpServlet {

	private static final long serialVersionUID = 1L;

	protected void doGet(	HttpServletRequest request, 
			HttpServletResponse response)
					throws IOException, ServletException{
				ServletContext context = this.getServletContext();
				ArrayList<String> nomsParties = new ArrayList<String>();
				for(int i=0 ; i < ((Main)context.getAttribute("Serveur")).getNomsParties().size() ; i++) {
					if (((Main)context.getAttribute("Serveur")).placesLibres(((Main)context.getAttribute("Serveur")).getNomsParties().get(i))) {
						nomsParties.add(((Main)context.getAttribute("Serveur")).getNomsParties().get(i));
					}
				}
				int nbParties = nomsParties.size();
				request.setAttribute("nbParties", nbParties);
				request.setAttribute("nomsParties", nomsParties);
				request.getRequestDispatcher("jsp/playerform.jsp").forward(request, response);
	}
}
